﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using WoChu.RfClient.Entity;

namespace WoChu.RfClient.Duty
{
    public class ProdOnShelvesUIRule
    {
        private static ProdOnShelvesUIRule _NewInstance = new ProdOnShelvesUIRule();

        public static ProdOnShelvesUIRule NewInstance
        {
            get
            {
                if (_NewInstance == null)
                {
                    _NewInstance = new ProdOnShelvesUIRule();
                }

                return _NewInstance;
            }
        }

        public ResultModel<List<GoodsBoxes>> GetGoodsBoxesByBoxCode(string code)
        {
            try
            {
                ResultModel<List<GoodsBoxes>> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IProdOnShelves>.NewInstance.InvokeWebMethod<ResultModel<List<GoodsBoxes>>>("GetGoodsBoxesByBoxCode", new object[] { code });
                if (_result == null)
                    return new ResultModel<List<GoodsBoxes>>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<List<GoodsBoxes>>().GetInstance();
            }
        }

        public ResultModel<bool> SetProdOnShelves(string userID, string locationCode, List<GoodsBoxes> lstGoodsBoxes)
        {
            try
            {
                ResultModel<bool> _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IProdOnShelves>.NewInstance.InvokeWebMethod<List<GoodsBoxes>, ResultModel<bool>>("SetProdOnShelves", new object[] { userID, locationCode }, lstGoodsBoxes);
                if (_result == null)
                    return new ResultModel<bool>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<bool>().GetInstance();
            }
           
        }

        public ResultModel<GoodsInfo> GetPickLoction(string goodscode)
        {
            try
            {
                var _result = WoChu.CF.BaseFrame.WebClient.WebGetHelper<IProdOnShelves>.NewInstance.InvokeWebMethod<ResultModel<GoodsInfo>>("GetPickLoction", new object[] { goodscode });
                if (_result == null)
                    return new ResultModel<GoodsInfo>().GetInstance();
                return _result;
            }
            catch (Exception ex)
            {
                WoChu.CF.BaseFrame.Util.MessageBoxEx.Show(ex);
                return new ResultModel<GoodsInfo>().GetInstance();
            }
            
        }
    }
}
